class Validators {
  context = null
  validateUsername = (rule, value, callback) => {
    let {usernameError} = this.context
    if (!value) {
      callback('请输入用户名')
    } else {
      callback(usernameError)
    }
  }
  validatePassword = (rule, value, callback) => {
    let {form} = this.context
    if (!value && !form.id) {
      callback('请输入密码')
    } else {
      callback()
    }
  }
  validateGender = (rule, value, callback) => {
    if (value === null || value === undefined || value === '') {
      callback('请选择性别')
    } else {
      callback()
    }
  }
  validateBirthday = (rule, value, callback) => {
    if (!value) {
      callback('请选择生日')
    } else {
      callback()
    }
  }
  validateEmail = (rule, value, callback) => {
    if (!value) {
      callback('请输入邮箱')
    } else {
      callback()
    }
  }
  validatePhone = (rule, value, callback) => {
    if (!value) {
      callback('请输入手机号码')
    } else {
      callback()
    }
  }
  validateProvinceCityArea = (rule, value, callback) => {
    if (!value || value.length === 0) {
      callback('请选择区域')
    } else {
      callback(undefined)
    }
  }
  validateAddress = (rule, value, callback) => {
    if (!value) {
      callback('请输入地址')
    } else {
      callback()
    }
  }
}

export default Validators
